package com.loong.musicdemo.ui.cloudtown.videos;

import android.content.Context;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import java.util.List;

/**
 * 用于实现viewpager滑动效果适配器
 */
public class SectionsPagerAdapter extends FragmentPagerAdapter {
    private final List<String> list;//分组信息

    public SectionsPagerAdapter(FragmentManager fm,List<String> list) {
        super(fm);
        this.list = list;
    }

    @NonNull
    @Override
    public Fragment getItem(int position) {
        return VideoPager.newInstance(list.get(position));
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {//返回分组名也即标题
        return list.get(position);
    }
}
